export default {
    data() {
      return {
        spinShow: false,
        VIRTUAL_PATH: process.env.VUE_APP_VIRTUAL_PATH,
        uploadUrl: process.env.VUE_APP_API_ROOT+ "/excel",
        currentStep: 0,
        excelTableData: [],
        excelTablCol: [
          {
            title: "字典全称",
            key: "字典全称",
            align: "center",
            width: 200,
            fixed: 'left'
          },
          {
            title: "字典简称",
            key: "字典简称",
            align: "center",
          },
          {
            title: "字典备注",
            key: "字典备注",
            align: "center",
          },
          {
            title: "字典类型",
            key: "字典类型",
            align: "center",
          },
          {
            title: "备注",
            key: "mark",
            slot: "mark",
            width:200,
            align: "center",
            fixed:"right"
          },
        ],
        resultType: "1",
        list: [],
      };
    },
    methods: {
      uploadExcelSuccess(res, file, fileList) {
        this.excelTableData = res.data;
        this.list = this.excelTableData
        this.currentStep = 2;
      },
      resultchange(value) {
        switch (value) {
          case "1":
            this.list = this.excelTableData.list;
            break;
          case "2":
            this.list = this.excelTableData.success;
            break;
  
          case "3":
            this.list = this.excelTableData.error;
            break;
        }
      },
      imporExcelData() {
        this.spinShow = true;
        if (this.excelTableData.length == 0) {
          this.$Message.warning("请先导入数据");
          this.spinShow = false;
          return;
        }
        //
      ;
        // let formdata = new FormData();
        // formdata.append("list", JSON.stringify(this.excelTableData));
        this.$axios({
          url: "/dict/list",
          method: "PUT",
          data: this.excelTableData,
        })
          .then((res) => {
            if (res.code == 200) {
              this.excelTableData = res.data;
              this.list = this.excelTableData.list;
              // this.getData();
              this.$emit("success", "");
            } else {
              this.$Message.error(res.msg);
            }
            this.spinShow = false;
          })
          .catch((error) => {
            this.spinShow = false;
            this.$Message.error(error.message);
          });
      },
    },
  };
  